/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/

#ifndef foominidumphfoo
#define foominidumphfoo

/***
  This file is part of libminidump.

  Copyright 2012 Lennart Poettering

  libminidump is free software; you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation; either version 2.1 of the
  License, or (at your option) any later version.

  libminidump is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with libminidump; If not, see
  <http://www.gnu.org/licenses/>.
***/

#include <sys/types.h>
#include <stdio.h>

/* Terms:
 *
 * coredump: an ELF coredump as generated by the kernel
 * minicore: a reduced size ELF coredump, augmented with userspace data
 * minidump: a Windows/Breakpad compatible minidump
 *
 * We can convert:
 *
 * A running process            → minidump
 * A running process            → minicore
 * A coredump                   → minidump
 * A coredump                   → minicore
 * A coredump + running process → minidump
 * A coredump + running process → minicore
 * A minidump                   → minicore
 *
 * A minicore may be used as input wherever a coredump is expected.
 *
 * The input coredump/minidump fds must be seekable.
 */

/* You may set either pid = 0 or coredump_fd = -1 but not both*/
int minidump_make(pid_t pid, int coredump_fd, void **minidump, size_t *size);

/* You may set either pid = 0 or coredump_fd = -1 but not both */
int minicore_make(pid_t pid, int coredump_fd, void **minicore, size_t *size);

int minidump_show(FILE *f, int minidump_fd);

/* You may set either pid = 0 or coredump_fd = -1 but not both */
int coredump_show(FILE *f, pid_t pid, int coredump_fd);

int minidump_to_minicore(int minidump_fd, void **minicore, size_t *size);

#endif
